package cn.bocweb.spinning.view.common;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.widget.TextView;

import cn.bocweb.spinning.R;

/**
 * Created by chenchangxing on 16/1/21.
 */
public class RotateTextView extends TextView {

    float withAdd;
    float heightAdd;

    public RotateTextView(Context context) {
        super(context);

    }

    public RotateTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
        TypedArray mTypedArray = context.obtainStyledAttributes(attrs,
                R.styleable.RotateTextView);

        withAdd = mTypedArray.getDimension(R.styleable.RotateTextView_withAdd, 0);
        heightAdd = mTypedArray.getDimension(R.styleable.RotateTextView_heightAdd, 0);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        canvas.rotate(34, getMeasuredWidth()/2 + withAdd, getMeasuredHeight()/2 + heightAdd);
        super.onDraw(canvas);
    }
}
